package com.ruoyi.qsng.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.uuid.SnowFlakeUtil;
import com.ruoyi.qsng.domain.KLearningHome;
import com.ruoyi.qsng.mapper.KLearningHomeMapper;
import com.ruoyi.qsng.service.IKLearningHomeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 学习之家Service业务层处理
 *
 * @author kanglou
 * @date 2023-06-07
 */
@Service
public class KLearningHomeServiceImpl implements IKLearningHomeService {
    @Autowired
    private KLearningHomeMapper kLearningHomeMapper;

    /**
     * 查询学习之家
     *
     * @param id 学习之家主键
     * @return 学习之家
     */
    @Override
    public KLearningHome selectKLearningHomeById(String id) {
        return kLearningHomeMapper.selectKLearningHomeById(id);
    }

    /**
     * 查询学习之家列表
     *
     * @param kLearningHome 学习之家
     * @return 学习之家
     */
    @Override
    public List<KLearningHome> selectKLearningHomeList(KLearningHome kLearningHome) {
        return kLearningHomeMapper.selectKLearningHomeList(kLearningHome);
    }

    /**
     * 新增学习之家
     *
     * @param kLearningHome 学习之家
     * @return 结果
     */
    @Override
    public int insertKLearningHome(KLearningHome kLearningHome) {
        kLearningHome.setId(SnowFlakeUtil.getNextId());
//        kLearningHome.setCreateTime(DateUtils.getNowDate());
        return kLearningHomeMapper.insertKLearningHome(kLearningHome);
    }

    /**
     * 修改学习之家
     *
     * @param kLearningHome 学习之家
     * @return 结果
     */
    @Override
    public int updateKLearningHome(KLearningHome kLearningHome) {
        kLearningHome.setUpdateTime(DateUtils.getNowDate());
        return kLearningHomeMapper.updateKLearningHome(kLearningHome);
    }

    /**
     * 批量删除学习之家
     *
     * @param ids 需要删除的学习之家主键
     * @return 结果
     */
    @Override
    public int deleteKLearningHomeByIds(String[] ids) {
        return kLearningHomeMapper.deleteKLearningHomeByIds(ids);
    }

    /**
     * 删除学习之家信息
     *
     * @param id 学习之家主键
     * @return 结果
     */
    @Override
    public int deleteKLearningHomeById(String id) {
        return kLearningHomeMapper.deleteKLearningHomeById(id);
    }
}
